package cn.webrx;

import java.util.TreeMap;

public class TreeMap1 {
    public static void main(String[] args) {
        //TreeMap<String,Integer> tm = new TreeMap<>((a,b)->b.compareTo(a));  字母降序
        //TreeMap<String,Integer> tm = new TreeMap<>(); key 字符串自然排序升序
        TreeMap<String,Integer> tm = new TreeMap<>((a,b)->b.compareTo(a));
        tm.put("java",500);
        tm.put("c",400);
        tm.put("go",200);
        tm.put("php",290);
        tm.put("python",390);
        tm.put("javascript",420);
        System.out.println(tm);
        System.out.println(tm.keySet());
        System.out.println(tm.values());

        //tm.keySet()
        //tm.values()

        //tm.entrySet()

        //Integer 降序
        var t = new TreeMap<Integer,String>((a,b)->b-a);
        t.put(16,"李四");
        t.put(200,"赵六");
        t.put(10,"张三丰");
        t.put(13,"李勇");
        System.out.println(t);


    }
}
